//--------------------------------------------------------------------------------
// This file is part of the Windows Workflow Foundation Sample Code
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This source code is intended only as a supplement to Microsoft
// Development Tools and/or on-line documentation.  See these other
// materials for detailed information regarding Microsoft code samples.
// 
// THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//--------------------------------------------------------------------------------

using System;
using System.Configuration;
using System.Collections.Specialized;

namespace Microsoft.Samples.Workflow.UI.Asp
{

    public class ExceptionMappingElementCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new ExceptionMappingElement();
        }

        protected override object GetElementKey(ConfigurationElement settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            return ((ExceptionMappingElement)settings).Type;
        }

        public void Add(ExceptionMappingElement mapping)
        {
            if (mapping == null)
            {
                throw new ArgumentNullException("mapping");
            }

            base.BaseAdd(mapping);
        }
    }

    public class ExceptionMappingElement : ConfigurationElement
    {
        private const string _type = "type";
        private const string _location = "location";

        public ExceptionMappingElement()
        {
        }

        [ConfigurationProperty(_type, DefaultValue = null)]
        public string Type
        {
            get
            {
                return (string)base[_type];
            }
            set
            {
                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }

                base[_type] = value;
            }
        }

        [ConfigurationProperty(_location, DefaultValue = null)]
        public string Location
        {
            get
            {
                return (string)base[_location];
            }
            set
            {
                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }

                base[_location] = value;
            }
        }
    }
}
